home *** CD-ROM | disk | FTP | other *** search
- unit UnitMain;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, HTTPApp;
-
- { This example web module returns a JPEG image of a TeeChart component.
- The Chart1 component is located in UnitChart.pas unit.
- }
- type
- TWebModule1 = class(TWebModule)
- procedure WebModule1WebActionItem1Action(Sender: TObject;
- Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- WebModule1: TWebModule1;
-
- implementation
-
- {$R *.DFM}
- Uses UnitChart;
-
- { This event is created at design-time, double-clicking the WebModule
- form and adding an action... }
- procedure TWebModule1.WebModule1WebActionItem1Action(Sender: TObject;
- Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
- Var Stream:TMemoryStream;
- begin
- With TForm2.Create(Self) do { create the Form where is the Chart1... }
- try
- With ChartToJPEG(Request) do { convert Chart1 to JPEG }
- try
- Stream:=TMemoryStream.Create; { create a temporary stream in memory... }
- try
- SaveToStream(Stream); { save the jpeg to the stream... }
- Stream.Position := 0;
- Response.ContentType:='image/jpeg'; { send the stream... }
- Response.ContentLength:=Stream.Size;
- Response.SendResponse;
- Response.SendStream(Stream);
- finally
- Stream.Free; { release the temporary stream... }
- end;
- finally
- Free; { <-- free the temporary JPEG object returned by ChartToJPEG }
- end;
- finally
- Free; { free the Form2 }
- end;
- end;
-
- end.
-